package org.dinnermate.db;

import java.sql.SQLException;

import net.java.ao.DBParam;
import net.java.ao.Entity;
import net.java.ao.EntityManager;

/**
 * Class to provide singleton access to the EntityManager
 * 
 * @see EntityManager
 * @author Jeff
 */
public class DBManager
{
	private static class EntityManagerHolder
	{
		private final static EntityManager INSTANCE = new EntityManager(
				"jdbc:mysql://localhost/dinnermate", "dinnermate", "!r00t");
	}

	public static EntityManager getEntityManager()
	{
		return EntityManagerHolder.INSTANCE;
	}
	
	public static <T extends Entity> T create(Class<T> type, DBParam... params) throws SQLException
	{
		return EntityManagerHolder.INSTANCE.create(type, params);
	}
}
